const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');

const router = require('./router.js');

const app = express();
const port = 8712;

app.use('/api/*', function(req, res, next) {
	res.header("Access-Control-Allow-Origin", "*");
	res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
	res.header("Access-Control-Allow-Methods", "POST,GET");
	next();
});
// bodyParse插件
app.use(bodyParser.urlencoded({
	extended: false
}))
app.use(bodyParser.json());
// 托管静态资源
app.use('/pubsrc', express.static(path.join(__dirname, 'public')));
// 服务路由
app.use(router);

app.listen(port, () => {
  console.log(`Luo app listening on port ${port}`)
})